package cn.tinlan.shopcoin.app.mine.set.adapter;

import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v7.widget.RecyclerView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;

import java.util.List;

import cn.tinlan.shopcoin.R;
import cn.tinlan.shopcoin.Utils.TimeUtil;
import cn.tinlan.shopcoin.app.mine.set.model.MoneyHistoryItemModel;

/**
 * Created by Mortimer on 2018/12/20. 16:48
 * 佛祖🙏，永无bug。
 */
public class MoneyHistoryAdapter extends BaseQuickAdapter <MoneyHistoryItemModel,BaseViewHolder>{

    private int history_type = 1;
    public MoneyHistoryAdapter(int layoutResId,int type ,@Nullable List data) {
        super(layoutResId, data);
        this.history_type = type;
    }

    @Override
    protected void convert(BaseViewHolder helper, MoneyHistoryItemModel item) {

        if (history_type == 1){
            helper.setText(R.id.history_item_tv,item.getChange_num());
            helper.setText(R.id.history_item_addtime, TimeUtil.timeStamp2Date(Integer.parseInt(item.getAddtime()),null));
        }else if (history_type == 2){
            helper.setText(R.id.history_item_tv,item.getPay_amount());
            helper.setText(R.id.history_item_addtime, TimeUtil.timeStamp2Date(Integer.parseInt(item.getAddtime()),null));
        }else {
            String type = "";
            if (item.getType().equals("1")){
                type = "余额充值";
            }else if (item.getType().equals("2")) {
                type = "商城购物";
            }else if (item.getType().equals("3")) {
                type = "余额提现";
            }else if (item.getType().equals("4")) {
                type = "赠送锦鲤";
            }else if (item.getType().equals("5")) {
                type = "接受锦鲤";
            }
            helper.setText(R.id.change_item_type,type);
            helper.setText(R.id.change_item_oldNum,item.getOld_num());
            helper.setText(R.id.change_item_newNum,item.getNew_num());
            helper.setText(R.id.change_item_changeNum,item.getChange_num());
            helper.setText(R.id.change_item_remark,item.getRemark());
            helper.setText(R.id.change_item_time,TimeUtil.timeStamp2Date(Integer.parseInt(item.getAddtime()),null));
        }



    }

}
